package com.gfxy.modules.index.controller;

import com.alibaba.fastjson.JSONObject;
import com.gfxy.modules.base.vo.TeacherBaseInfoVo;
import com.gfxy.modules.index.service.AssessmentService;
import com.gfxy.modules.items.service.DictTranslater;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: lijixin 2021/10/21 9:06 下午
 */
@Api(tags="教师结果详情报表")
@RestController
@RequestMapping("index/commonAssessment")
@Slf4j
public class CommonAssessmentServiceController {

    @Autowired
    private AssessmentService assessmentService;

    @Autowired
    protected DictTranslater dictTranslater;


    @AutoLog(value = "根据用户名查询用户基本信息")
    @ApiOperation(value="根据用户名查询用户基本信息", notes="根据用户名查询用户基本信息")
    @GetMapping(value = "/getTeacherBaseInfoByUserName")
    public Result<?> getTeacherBaseInfoByUserName(@RequestParam(name="username",required=true) String username,
                                                  HttpServletRequest req) {
        log.debug("开始查询教师[{}]的基本信息",username);
        List<TeacherBaseInfoVo> teacherBaseInfo = assessmentService.getTeacherBaseInfo(username);
        return Result.OK(teacherBaseInfo);
    }


    @AutoLog(value = "根据用户名查询用户积分及排名")
    @ApiOperation(value="根据用户名查询用户积分及排名", notes="根据用户名查询用户积分及排名")
    @GetMapping(value = "/getTeacherScoreAndRankedByUsernameAndDate")
    public Result<JSONObject> getTeacherScoreAndRankedByUsernameAndDate(
            @RequestParam(name="username",required=true) String username,
            @RequestParam(name="orgCode",required=true) String orgCode,
            @RequestParam(name="date",required=true) String date,
            @RequestParam(name="projectId",required = true) String projectId,
            HttpServletRequest req) {
        log.debug("开始查询教师[{}]的课时积分", username);
        JSONObject result = assessmentService.getTeacherScoreAndRankedByUsernameAndDate(date,orgCode,username,projectId);
        return Result.OK(result);
    }




}
